package com.yyplatform.admin.platform.generator.controller;

import static com.yyplatform.admin.Constants.URL_PREFIX;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yyplatform.admin.infra.model.RestResponse;
import com.yyplatform.admin.platform.generator.model.dto.CodeGenDTO;
import com.yyplatform.admin.platform.generator.service.CodeGenService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author sleepforests@163.com
 * <p>
 * Created on 2024/9/22 21:09
 */
@Slf4j
@Tag(name = "开发/代码生成")
@AllArgsConstructor
@RestController
@RequestMapping(URL_PREFIX + "/generator/codeGen/")
public class CodeGenController {

    private CodeGenService codeGenService;

    @GetMapping("generator")
    @Operation(summary = "代码生成")
    @RequiresPermissions("sys:codeGen:generator")
    public RestResponse<CodeGenDTO> generator(Long id) {
        log.debug("generator id is {}", id);


        CodeGenDTO codeGenDTO = codeGenService.generatorCode(id);

        return RestResponse.ok(codeGenDTO);
    }

}
